<?php

/**
 * FreeY_Msg 
 *
 * @category   
 * @package    
 * @subpackage 
 * @copyright  
 * @license    
 */
class FreeY_Msg
{
	/**
	 * alert message
	 *
	 * @param $var
	 * @return viod
	 */
	static public function msg($text, $urlstr = "")
	{
		if(!DEBUG_SQL_ECHO)
		{
			exit($text);
		}
		if(!$text)
		{
			if($urlstr){
				exit(self::getHref($urlstr));
			} else {
				exit(self::getHistory('-1'));
			}
		}
		else
		{
			if($urlstr){
				exit(self::getAlert($text) . self::getHref($urlstr));
			}
			else {
				exit(self::getAlert($text) . self::getHistory('-1'));
				if($urlstr===0)return  1;
				else exit;
			}	
		}	
	}
	/**
	 * Js.Alert.string
	 *
	 * @param $var
	 * @return viod
	 */
	static public function getAlert($msg)
	{
		return self::_getScript('alert("'.$msg.'");');
	}	
	/**
	 * Js.Href.string
	 *
	 * @param $var
	 * @return viod
	 */
	static public function getHref($url)
	{
		return self::_getScript('window.location.href="'.$url.'";');
	}	
	/**
	 * Js.History.string
	 *
	 * @param $var
	 * @return viod
	 */
	static public function getHistory($go)
	{
		return self::_getScript('window.history.go(' . (int)($go) . ');');
	}	
	/**
	 * Js.Script.string
	 *
	 * @param $var
	 * @return viod
	 */
	private function _getScript($js)
	{
		return '<Script>' . $js . '</Script>';
	}	
	/**
	 * Js.Reload.string
	 *
	 * @param $var
	 * @return viod
	 */
	static public function getReload()
	{
		return self::_getScript('location.reload();');
	}	
	/**
	 * Js.altReload.string
	 *
	 * @param $var
	 * @return viod
	 */
	static public function altReload($msg)
	{
		exit(self::getAlert($msg) . self::getReload());
	}	
}
//file end--------------------------------------------------------->